<?
 	if (file_exists('../settings.php')) {
 		include('../settings.php');
 		header('Location: '.$XDESK_CI_CONFIG['base_url']);
 		die();
 	}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html lang="en"> 
<head> 
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
	<meta http-equiv="PRAGMA" content="NO-CACHE"> 
	<meta http-equiv="CACHE-CONTROL" content="NO-CACHE"> 
	<meta http-equiv="EXPIRES" content="-1"> 

	<!-- EXT JS LIBRARY --> 
	<!-- Using cachefly --> 
	<link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-3.2.1/resources/css/ext-all-notheme.css" /> 
	<script type="text/javascript" src="http://extjs.cachefly.net/ext-3.2.1/adapter/ext/ext-base.js"></script> 
	<script type="text/javascript" src="http://extjs.cachefly.net/ext-3.2.1/ext-all.js"></script> 
	
	<link rel="stylesheet" type="text/css" href="../resources/css/xtheme-gray.css" />
	
	<style>
		html {
			overflow: auto;
		}
		body {
			background-image: url(../resources/wallpapers/xdesk2.jpg);
			background-repeat: no-repeat;
			background-attachment:fixed;
			background-position: center center;
			background-color: #000000;
		}
		.win-icon { background-image: url(../resources/icons/16x16/xdesk2.png) !important; 
	</style>
	
	<title>xDesk 2 Installation</title> 
	
	<script type="text/javascript">
		InstallWindow = Ext.extend(Ext.Window, {
			title: 'xDesk 2 Installation',
			iconCls: 'win-icon',
			width: 536,
			height: 424,
			resizable: false,
			closable: false,
			layout: 'fit',
			initComponent: function() {
				this.items = [
					{
						id: 'installForm',
						xtype: 'form',
						width: 522,
						height: 495,
						padding: 10,
						method: 'POST',
						items: [
							{
								xtype: 'fieldset',
								title: 'MySQL',
								items: [
									{
										xtype: 'textfield',
										fieldLabel: 'Server',
										anchor: '100%',
										name: 'mysql_server',
										value: 'localhost',
										allowBlank: false
									},
									{
										xtype: 'textfield',
										fieldLabel: 'User',
										anchor: '100%',
										name: 'mysql_user',
										value: 'root',
										allowBlank: false
										
									},
									{
										xtype: 'textfield',
										fieldLabel: 'Password',
										anchor: '100%',
										inputType: 'password',
										name: 'mysql_password'
									}
								]
							},
							{
								xtype: 'fieldset',
								title: 'HTTP Server',
								items: [
									{
										xtype: 'textfield',
										fieldLabel: 'Disk path',
										anchor: '100%',
										name: 'base_path',
										value: '<?=str_replace('install/index.php','',$_SERVER['SCRIPT_FILENAME']);?>',
										allowBlank: false
									},
									{
										xtype: 'textfield',
										fieldLabel: 'URL',
										anchor: '100%',
										name: 'base_url',
										value: '<?$url=(!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];echo str_replace('install/','',$url);?>',
										allowBlank: false
									}
								]
							},
							{
								xtype: 'fieldset',
								title: 'Administrator account',
								items: [
									{
										xtype: 'textfield',
										fieldLabel: 'Name',
										anchor: '100%',
										value: '<?$k=file_get_contents('http://www.behindthename.com/random/random.php?number=2&gender=both&surname=&all=no&usage_trans=1');$w=stripos($k,'Your random name is:');$w2=stripos($k,'</font></center><br><br><br>');$j=substr($k,$w+20,$w2-($w+20));echo trim(str_replace('  ',' ',str_replace("\n",'',strip_tags($j))));?>',
										allowBlank: false
									},
									{
										xtype: 'textfield',
										fieldLabel: 'User',
										value: 'admin',
										anchor: '100%',
										allowBlank: false										
									},
									{
										xtype: 'textfield',
										fieldLabel: 'Password',
										anchor: '100%',
										inputType: 'password',
										allowBlank: false
									}
								]
							},
							{
								xtype: 'button',
								text: 'Install',
								type: 'submit',
								width: 88,
								handler: function() {
									Ext.getCmp('installForm').getForm().submit({  
										url : 'install.php',  
										waitMsg : 'Installing xDesk 2...',  
										failure: function (form, action) {  
											Ext.MessageBox.show({  
												title: 'Installation error',
												msg: 'An error ocurred while installing xDesk 2, check your configuration data.',  
												buttons: Ext.MessageBox.OK,  
												icon: Ext.MessageBox.ERROR  
											});  
										},  
										success: function (form, request) {  
											Ext.MessageBox.show({  
												title: 'Installation success',  
												msg: 'Your xDesk 2 is ready to use.',  
												buttons: Ext.MessageBox.OK,  
												icon: Ext.MessageBox.INFO  
											});
											win.hide();
										}
									});
								}
							}
						]
					}
				];
				InstallWindow.superclass.initComponent.call(this);
			}
		});
		var win = new InstallWindow();
		Ext.onReady(function() {
			win.show();
		});
	</script>
</head>

<body scroll="no">
	
</body>